<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/include/jQgrid.jsp"%>

</head>
<body style="background-color: white;" class="gray-bg">
                    <div class="ibox-content">
                        <form  class="form-horizontal m-t" id="signupForm">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">部门名称：</label>
                                <div class="col-sm-8">
                                    <input id="depName" name="depName" value="" class="form-control" type="text">
                                    <input name="pid" type="hidden"  value="${id}" >
                                    <input name="level" type="hidden"  value="${level}" >
                                    <input name="state" type="hidden"  value="1" >
                                    <span class="help-block m-b-none"><i class="glyphicon glyphicon-info-sign"></i>部门名是唯一存在</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">部门地址：</label>
                                <div class="col-sm-8">
                                    <input id="address" name="address" value="" class="form-control" type="text" aria-required="true" aria-invalid="false" class="valid">
                                </div>
                            </div>
                          
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary" type="button" id="sub">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
	<script>
	$(function(){
		$("#sub").click(function(){
			var depName = $("#depName").val();
			if(depName.length==0){
				$("#depName").tips({
					side:3,
		            msg:'部门不能为空！',
		            bg:'#AE81FF',
		            time:1
		        });
				$("#depName").focus();
				return;
			}
			
			if($("#address").val().length==0){
				$("#address").tips({
					side:3,
		            msg:'地址不能为空！',
		            bg:'#AE81FF',
		            time:1
		        });
				$("#address").focus();
				return;
			}
			$("#signupForm").ajaxSubmit({
	        	url:'<%=contextPath %>/dep/add',
	        	type:'post',
	        	dataType:"json",
	        	success:function(data){
	        		if(data.code==200){
	        			swal({
	        			    title: data.message,
	        			    type: "success",
	        			    showCancelButton: false,
	        			    confirmButtonText: "确定",
	        			    animation:"slide-from-bottom",
	        			    closeOnConfirm: true
	        			},function(){
	        				top.Dialog.close();
	        			});
	        		}else{
	        			swal("错误", data.message, "error");
	        		}
	        	}
	      }); 
		});
	});
	</script>
</body>
</html>